<template>
  <div class="details-header-cell">
    <div class="header-cell"
         v-for="(item, index) in detailsData.sublist" :key="index">
      <div class="cell-per">
        <div class="cell-left">
          <img :src="item.img">
          <div class="left-info">
            <div class="title">{{item.pdname}}</div>
            <div class="skus">{{item.psname}}</div>
          </div>
        </div>
        <div class="cell-right">
          <div class="price">{{item.psprice}}</div>
          <div class="num">x{{item.detailrnumber}}</div>
        </div>
      </div>
      <div class="cell-dividing"></div>
    </div>
    <div class="header-words">
      <div class="static-tip">我的留言:</div>
      <div class="words">{{detailsData.leaveword}}</div>
    </div>
  </div>
</template>

<script>
import mixins from '@/mixins'
export default {
  mixins: [mixins],
  name: 'details-header-cell',
  data () {
    return {
      headerList: [],
      type: 4
    }
  },
  props: {
    detailsData: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  computed: {
    setIconImage () {
      let obj = this.headerList[this.type]
      if (obj) {
        return this.setLocalImg(obj.imgUrl)
        // backgroundImage: this.setLocalImg(obj.imgUrl),
        // backgroundSize: `${obj.width / 100}rem ${obj.height / 100}rem`,
        // width: `${obj.width / 100}rem`,
        // height: `${obj.height / 100}rem`
      }
    },
    setIconStyle () {
      let obj = this.headerList[this.type]
      if (obj) {
        return {
          width: `${obj.width / 100}rem`,
          height: `${obj.height / 100}rem`
        }
      }
    }
  },
  methods: {
    initObj () {
      this.spwanObj('icon-status-waitpay', '待付款', 31, 34)
      this.spwanObj('icon-status-close', '已关闭', 34, 34)
      this.spwanObj('icon-status-waitdelivery', '待发货', 34, 31)
      this.spwanObj('icon-status-delivery', '已发货', 34, 27)
      this.spwanObj('icon-status-success', '已完成', 34, 34)
    },
    spwanObj (imgUrl, text, width, height) {
      this.headerList.splice(this.headerList.length, 0, { imgUrl: imgUrl, text: text, width: width, height: height })
    }
  },
  mounted () {
    this.initObj()
    this.BIND_LOADING(false)
  }
}
</script>

<style lang="stylus" scoped>
.details-header-cell {
  background: white;

  .header-cell {
    .cell-per {
      display: flex;
      padding-left: 31px;
      padding-top: 25px;
      padding-bottom: 20px;
      padding-right: 20px;

      .cell-left {
        display: flex;

        img {
          width: 132px;
          height: 132px;
        }

        .left-info {
          margin-left: 20px;
          height: 132px;
          display: flex;
          flex-direction: column;

          .title {
            font-size: 26px;
            color: rgba(51, 51, 51, 1);
          }

          .skus {
            display: flex;
            flex: 1;
            align-items: flex-end;
            font-size: 24px;
            padding-bottom: 13px;
            color: rgba(153, 153, 153, 1);
          }
        }
      }

      .cell-right {
        flex: 1;
        display: flex;
        align-items: flex-end;
        flex-direction: column;

        .price {
          font-size: 26px;
          color: rgba(51, 51, 51, 1);
        }

        .num {
          font-size: 26px;
          display: flex;
          flex-direction: column;
          justify-content: flex-end;
          color: rgba(153, 153, 153, 1);
        }
      }
    }

    .cell-dividing {
      width: 95%;
      height: 1px;
      background: RGBA(238, 238, 238, 1);
      margin-left: 20px;
      margin-right: 20px;
      box-sizing: border-box;
    }
  }

  .header-words {
    font-size: 28px;
    display: flex;
    padding-left: 21px;
    padding-right: 20px;
    padding-top: 20px;
    padding-bottom: 20px;

    .static-tip {
      width: 20%;
      color: rgba(51, 51, 51, 1);
      margin-right: 20px;
    }

    .words {
      width: 80%;
      color: rgba(102, 102, 102, 1);
    }
  }
}
</style>
